import request from '@/utils/request'

const URL = 'user'

export function userLogin(username, password) {
  return request({
    url:  'login/user',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

export function userLogout() {
  return request({
    url: URL + '/logout',
    method: 'get'
  })
}

export function userRegister(data) {
  return request({
    url: URL + '/register',
    method: 'post',
    data: data
  })
}

export function getCode(phone) {
  return request({
    url: URL + '/getCode',
    method: 'post',
    data: {
      phone
    }
  })
}
export function retrievePassword(from) {
  return request({
    url: URL + '/retrievePassword',
    method: 'post',
    data: {
      phone: from.phone,
      code: from.code,
      password: from.password,
      confirmPassword: from.confirmPassword
    }
  })
}
export function getUserInfoByUsername(username) {
  return request({
    url: URL + '/withUsername',
    method: 'post',
    data: {
      username
    }
  })
}

export function getUserInfo() {
  return request({
    url: URL + '/profile',
    method: 'post',
    data: {
      // username
    }
  })
}

export function getUserInfoById(id) {
  return request({
    url: URL + '/getUserById/'+id,
    method: 'get',
    // data: {
    //   userId: id
    // }
  })
}

